{include file="public/com_header"}

<body style="padding:10px;">
    <div class="tplay-body-div">
        <fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;border:0">
        <!--<form id="downloadImageForm" class="layui-form serch" action="{:url('admin/Tools/downloadImage')}" method="post">-->
        <form id="hashidsStrForm" class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label"> 加密字符串 </label>
                <div class="layui-input-inline">
                  <input type="text" name="id_str" lay-verify="title" autocomplete="off" placeholder="请输入Str" class="layui-input" style="width: 500px;">
                </div>
                <div class="layui-input-block" style="float:right;right:50px;">
                    <button class="layui-btn layui-btn-sm layui-btn-normal " lay-submit lay-filter="HashidsStr">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-sm layui-btn-primary">重置</button>
                </div>
            </div>

            <!--<div class="layui-form-item">-->
                <!--<div class="layui-input-block">-->
                    <!--<button class="layui-btn" lay-submit lay-filter="HashidsStr">立即提交</button>-->
                    <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
                <!--</div>-->
            <!--</div>-->
        </form>
            <form  id="uniqidStrForm" class="layui-form">
                <div class="layui-form-item">
                    <label class="layui-form-label"> 生成唯一ID </label>
                    <div class="layui-input-inline">
                        <input type="text" name="uniqid_str" lay-verify="title" autocomplete="off" placeholder="随机生成唯一标识" class="layui-input" style="width: 500px;" readonly="readonly";>
                    </div>
                    <div class="layui-input-block" style="float:right;right:50px;">
                        <button class="layui-btn layui-btn-normal layui-btn-sm" lay-submit lay-filter="uniqidStr">生成</button>
                    </div>
                </div>
            </form>
        </fieldset>
        <script>
            layui.use(['layer', 'form'], function() {
                var layer = layui.layer,
                    $ = layui.jquery,
                    form = layui.form;
                $(window).on('load', function() {
                    form.on('submit(HashidsStr)', function(data) {
                        $.ajax({
                            url:"{:url('admin/Tools/hashids')}",
                            data:$('#hashidsStrForm').serialize(),
                            type:'post',
                            async: false,
                            success:function(res) {
                                if(res.code == 1) {
                                    // var htmlStr = '<lable class="layui-lable"> 加密后的Code ： </lable><span>'+res.msg+'</span>';
                                    // layer.alert(htmlStr)
                                    layer.alert(res.msg)
                                } else {
                                    layer.alert("输入字符串为空！")
                                }
                            }
                        })
                        return false;
                    });

                    form.on('submit(uniqidStr)', function(data) {
                        $.ajax({
                            url:"{:url('admin/Tools/uniqidCode')}",
                            data:" ",
                            type:'post',
                            async: false,
                            success:function(res) {
                                if(res.code == 1) {
                                    var htmlStr = '<lable class="layui-lable"> 唯一的标识</lable><br><span>'+res.msg+'</span>';
                                    layer.alert(htmlStr);
                                    // layer.alert(res.msg)
                                } else {
                                    layer.alert("生成失败！")
                                }
                            }
                        })
                        return false;
                    });
                });
            });
        </script>




    </div>
</body>
</html>
